package com.bosi.dalian.controller;

import com.bosi.dalian.config.DataSourceConfig;
import com.bosi.dalian.config.DataSourceContextHolder;
import com.bosi.dalian.service.DaLianService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = { "dalian" })
@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
@RequestMapping("/dalian")
@Slf4j
public class DaLianController {

    @Autowired
    private DaLianService daLianService;


    @RequestMapping(value="/test",method= RequestMethod.GET)
    public String test() {
        daLianService.saveBusi();
        daLianService.saveDalian();
        return "SUCCESS";
    }

    @RequestMapping(value="/test1",method= RequestMethod.GET)
    public String test1() {
        daLianService.saveBusi();
        return "SUCCESS";
    }

    @RequestMapping(value="/test2",method= RequestMethod.GET)
    public String test2() {
        DataSourceContextHolder.setDataSource(DataSourceConfig.DL_DATASOURCE_KEY);
        daLianService.saveDalian();
        return "SUCCESS";
    }
}
